-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add BeforeAll and AfterAll hooks #1569
Conversation
So, I choose not to share the But still, BeforeAll and AfterAll could be used for globally settin-up and cleaning-up things like database, browsers, and things related to the subject under test. What do you think? |
Question: should we prevent invoking those hooks in dry-run? |
No they should not, it doesn't make sense and doesn't cause any issues
That's fine, but in my eyes why don't we just move the logic from AfterConfiguration to BeforeAll - maybe over 2 majors. The concept of anything with the word
Yes because dry-run should concern itself with things that a feature/scenario may or may not do (Not a suite). But I am not overly concerned with this |
👍
So I would suggest to deprecate AfterConfiguration in favor of InstallPlugin rather than BeforeAll. InstallPlugin hook has the configuration object, BeforeAll has not.
👍 |
As part of this PR, I've added a short document to summarize all the hooks and their purpose. Could you please review it? It is there: features/docs/writing_support_code/hooks/README.md |
2 second look looks good for docs, I'll have plenty of review comments but it'll be minor polishes. I'll get to reviewing it in the next day or so. (if you can hold out till then that'll be good). |
No worries, no rush, take your time :) |
features/docs/writing_support_code/hooks/before_all_hook.feature
Outdated
Show resolved
Hide resolved
There is a use-case for these hooks being able to set some kind of read-only initial state/context so that, for example, you could access the database connection you created in the For example, we could pass a reference to a mutable Of course, we can do that as a second iteration. |
As you said, I suggest to do that as part of a second iteration, or even just waiting for user feedback and requests |
Description
Adding BeforeAll and AfterAll hooks. They are executed before all scenarios are executed and
after all scenarios have been executed.
Like the javascript ones, they do not have access to the
World
and they cannot mutate the test environment. Their purpose is to set-up and/or clean-up external things like databases or browsers.I choose to keep the AfterConfiguration hook as-is. We could consider its purpose not totally the same: AfterConfiguration has access to the configuration, and can even update it. BeforeAll cannot. This is still opened to discussion :p
Type of change
Please delete options that are not relevant.
Update required of cucumber.io/docs
If the Cucumber documentation requires an update,
submit a PR to cucumber/docs and
reference it here.
e.g. "Ref: cucumber/docs/pull/#99"
Checklist:
Your PR is ready for review once the following checklist is
complete. You can also add some checks if you want to.
bundle exec rubocop
reports no offenses